﻿@model Jb.Web.ViewModels.PackageViewModel

@{
    if(UserInfo.IsCompanyUser){
        Layout = "~/Views/Shared/_LayoutPrivate.cshtml";
        ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = EmployerMenu.Subscriptions;
    }
    String pageTitle = "Subscribe to a Package";
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    bool _IsPost = WebUtil.GetQueryStringBoolean("IsPost");
    bool _IsSaved = WebUtil.GetQueryStringBoolean("IsSaved");
    int _StatusCode = WebUtil.GetQueryStringInt("Status"); 
}

<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        @if (_IsPost)
        {
            <text>Package Subscription Result.</text>
        }
        else if (Model != null && Model.Price > 0) {
            <text>Verify the details of the package before payment.</text>
        }
        else {
            <text>Verify package details.</text>
        }        
    </div>
</div>
<div class="jb-page-content">
    @if (_IsPost)
    {
        if (_IsSaved) {
            if (_StatusCode == 10) {
            @Html.SuccessMessageBox(String.Format("Thank you for subscribing to the package \"{0}\". Now you can post jobs and search job seeker's resumes. ", Model.Name))
            }            
        }
        else if (!_IsSaved)
        {
            if (_StatusCode == 1)
            {
            @Html.WarningMessageBox("Sorry! the requested package was not found for subscription.");
            }
            else if (_StatusCode == 2)
            {
            @Html.WarningMessageBox("Sorry! this is a paid package.");
            }
            else if (_StatusCode == 3)
            {
            @Html.WarningMessageBox("Sorry! you have already subscribed to a package.");
            }
            else if (_StatusCode == 12)
            {
                @Html.WarningMessageBox(String.Format("Sorry! you need to log in as an Employer to subscribe to the package \"{0}\".", Model.Name))    
            }
            else
            {
                @Html.WarningMessageBox("Sorry! unable to subscribe you to the requested package.");
            }
        }
    }
    else if (!_IsPost)
    {
        if (Model != null)
        {
        <div style="margin:0px 0px 10px 0px;"><h3>@Model.Name</h3></div>
        <div>Price: @if (Model.Price <= 0)
                    {
                        <text>Free</text>
                    }
                    else
                    {
                        @Html.FormatData(Model.Price)
                    }
        </div>
        <div>Job Post Limit: @if (Model.MaxJobPost == -1)
                            { 
                                 <text>Unlimited</text>
                            }
                            else
                            {
                                 @Html.FormatData(Model.MaxJobPost)
                            }
        </div>
        <div>Resume Download Limit: @if (Model.MaxResumeDownload == -1)
                                   { 
                                 <text>Unlimited</text>
                                   }
                                   else
                                   {
                                 @Html.FormatData(Model.MaxResumeDownload)
                                   }
        
        </div>
        <div class="jb-button-container">        
                                   @using (Html.BeginForm())
                                   {
                                       if (Model.Price <= 0)
                                       {
            <button type="submit" class="btn btn-primary">Subscribe</button>
                                       }
                                       else
                                       {
            <input type="hidden" name="Price" value="@Model.Price" />
            <button type="submit" class="btn btn-primary">Make Payment</button>
                                       }
                                   }
        </div>
        }
        else
        {
        @Html.WarningMessageBox("Sorry! the requested package was not found.");
        }
    }
</div>